package simbot.example.data.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import simbot.example.data.domain.MnFans;
import simbot.example.data.mapper.MnFansMapper;
import org.springframework.stereotype.Service;
import simbot.example.data.service.MnFansService;

import java.util.List;

/**
 *
 */
@Service
public class MnFansServiceImpl extends ServiceImpl<MnFansMapper, MnFans>
        implements MnFansService {
    @Autowired
    private MnFansMapper mnFansMapper;

    @Override
    public Boolean selectAllByUserIdAndName(Long userId, String name) {
        MnFans mnFans = mnFansMapper.selectAllByUserIdAndName(userId, name);
        if(ObjectUtil.isNull(mnFans)){
            return false;
        }
        return true;
    }

    @Override
    public MnFans findAllByUserIdAndName(Long id, String s) {
        QueryWrapper<MnFans> wrapper =  new QueryWrapper();
        wrapper.eq("user_id",id);
        wrapper.eq("name",s);
        MnFans mnFans = mnFansMapper.selectOne(wrapper);
        return mnFans;
    }

    @Override
    public List<MnFans> selectByUserId(Long id) {
        QueryWrapper<MnFans> wrapper =  new QueryWrapper();
        wrapper.eq("user_id",id);
        List<MnFans> mnFans = mnFansMapper.selectList(wrapper);
        return mnFans;
    }
}




